/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Opcoes.java
 *
 * Created on 14/11/2011, 19:18:08
 */
package gerenciadorescola.view;

import gerenciadorescola.model.Turma;
import gerenciadorescola.model.pattern.facade.Fachada;
import java.awt.Image;
import java.awt.Toolkit;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;

/**
 *
 * @author Pedro Freitas
 */
public class Opcoes extends javax.swing.JFrame {

    /** Creates new form Opcoes */
    public Opcoes() {
        initComponents();
        try {
            Image icon = Toolkit.getDefaultToolkit().getImage("src/gerenciadorescola/imagens/uff.png");
            setIconImage(icon);
        } catch (Exception e) {
            e.getStackTrace();
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPopupMenu1 = new javax.swing.JPopupMenu();
        opcoesMenuBar = new javax.swing.JMenuBar();
        arquivoMenu = new javax.swing.JMenu();
        cadastrarMenuIntem = new javax.swing.JMenuItem();
        excluirMenuItem = new javax.swing.JMenuItem();
        logoutMenuItem = new javax.swing.JMenuItem();
        editarMenu = new javax.swing.JMenu();
        exibirMenu = new javax.swing.JMenu();
        exibirDiretorMenu = new javax.swing.JMenuItem();
        buscarMenuItem = new javax.swing.JMenuItem();
        jMenu1 = new javax.swing.JMenu();
        listarTMenuItem = new javax.swing.JMenuItem();
        listarAMenuItem = new javax.swing.JMenuItem();
        listarPMenuItem = new javax.swing.JMenuItem();
        ajudaMenu = new javax.swing.JMenu();
        sobreMenu = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Gerenciador de Escola TPA");

        arquivoMenu.setText("Arquivo");

        cadastrarMenuIntem.setText("Cadastar");
        cadastrarMenuIntem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cadastrarMenuIntemActionPerformed(evt);
            }
        });
        arquivoMenu.add(cadastrarMenuIntem);

        excluirMenuItem.setText("Excluir");
        excluirMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                excluirMenuItemActionPerformed(evt);
            }
        });
        arquivoMenu.add(excluirMenuItem);

        logoutMenuItem.setText("Logout");
        logoutMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                logoutMenuItemActionPerformed(evt);
            }
        });
        arquivoMenu.add(logoutMenuItem);

        opcoesMenuBar.add(arquivoMenu);

        editarMenu.setText("Editar");
        editarMenu.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                editarMenuMouseClicked(evt);
            }
        });
        editarMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                editarMenuActionPerformed(evt);
            }
        });
        opcoesMenuBar.add(editarMenu);

        exibirMenu.setText("Exibir");

        exibirDiretorMenu.setText("Diretor");
        exibirDiretorMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                exibirDiretorMenuActionPerformed(evt);
            }
        });
        exibirMenu.add(exibirDiretorMenu);

        buscarMenuItem.setText("Buscar");
        buscarMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buscarMenuItemActionPerformed(evt);
            }
        });
        exibirMenu.add(buscarMenuItem);

        jMenu1.setText("Listar");

        listarTMenuItem.setText("Turmas");
        listarTMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                listarTMenuItemActionPerformed(evt);
            }
        });
        jMenu1.add(listarTMenuItem);

        listarAMenuItem.setText("Alunos");
        listarAMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                listarAMenuItemActionPerformed(evt);
            }
        });
        jMenu1.add(listarAMenuItem);

        listarPMenuItem.setText("Professores");
        listarPMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                listarPMenuItemActionPerformed(evt);
            }
        });
        jMenu1.add(listarPMenuItem);

        exibirMenu.add(jMenu1);

        opcoesMenuBar.add(exibirMenu);

        ajudaMenu.setText("Ajuda");

        sobreMenu.setText("Sobre");
        sobreMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                sobreMenuActionPerformed(evt);
            }
        });
        ajudaMenu.add(sobreMenu);

        opcoesMenuBar.add(ajudaMenu);

        setJMenuBar(opcoesMenuBar);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 279, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void sobreMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sobreMenuActionPerformed
        JOptionPane.showMessageDialog(rootPane, "\n Trabalho de Técnicas de Programação Avançada - UFF\n\n Desenvolvedores: \n  -Hudson Gomes \n  -Pedro Freitas\n 2011");
    }//GEN-LAST:event_sobreMenuActionPerformed

    private void logoutMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_logoutMenuItemActionPerformed
        Login login = new Login();
        login.setLocation(300, 200);
        login.setVisible(true);
        this.dispose();
    }//GEN-LAST:event_logoutMenuItemActionPerformed

    private void cadastrarMenuIntemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cadastrarMenuIntemActionPerformed
       Cadastra cadastra = new Cadastra();
       cadastra.setLocation(300, 200);
       cadastra.setVisible(true);
    }//GEN-LAST:event_cadastrarMenuIntemActionPerformed

    private void excluirMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_excluirMenuItemActionPerformed
       Exclui exclui = new Exclui();
       exclui.setLocation(300, 200);
       exclui.setVisible(true);
    }//GEN-LAST:event_excluirMenuItemActionPerformed

    private void editarMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editarMenuActionPerformed
//        Edita edita = new Edita();
//        edita.setLocation(300, 200);
//        edita.setVisible(true);
    }//GEN-LAST:event_editarMenuActionPerformed

    private void exibirDiretorMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exibirDiretorMenuActionPerformed
        ExibiDiretor exibi = new ExibiDiretor();        
        exibi.setLocation(300, 200);
        exibi.setVisible(true);
    }//GEN-LAST:event_exibirDiretorMenuActionPerformed

    private void buscarMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buscarMenuItemActionPerformed
        Busca busca = new Busca();
        busca.setLocation(300, 200);
        busca.setVisible(true);
    }//GEN-LAST:event_buscarMenuItemActionPerformed

    private void editarMenuMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_editarMenuMouseClicked
        Edita edita = new Edita();
        edita.setLocation(300, 200);
        edita.setVisible(true);
    }//GEN-LAST:event_editarMenuMouseClicked

    private void listarTMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_listarTMenuItemActionPerformed
        Map<Integer, Turma> turmas = null;
        try {
            turmas = Fachada.ComandoListaTurmas(null);
        } catch (Exception ex) {
            System.out.println("Erro");
        }
        if (turmas.isEmpty()) {
            JOptionPane.showMessageDialog(rootPane, "Não existem turmas cadastrados na escola!");
        } else {
            ListaTurmas lista = new ListaTurmas(turmas);
            lista.setLocation(300, 200);
            lista.setVisible(true);
        }
    }//GEN-LAST:event_listarTMenuItemActionPerformed

    private void listarAMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_listarAMenuItemActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_listarAMenuItemActionPerformed

    private void listarPMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_listarPMenuItemActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_listarPMenuItemActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                Opcoes opcoes = new Opcoes();
                opcoes.setLocation(300, 200);
                opcoes.setVisible(true);
                
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenu ajudaMenu;
    private javax.swing.JMenu arquivoMenu;
    private javax.swing.JMenuItem buscarMenuItem;
    private javax.swing.JMenuItem cadastrarMenuIntem;
    private javax.swing.JMenu editarMenu;
    private javax.swing.JMenuItem excluirMenuItem;
    private javax.swing.JMenuItem exibirDiretorMenu;
    private javax.swing.JMenu exibirMenu;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JPopupMenu jPopupMenu1;
    private javax.swing.JMenuItem listarAMenuItem;
    private javax.swing.JMenuItem listarPMenuItem;
    private javax.swing.JMenuItem listarTMenuItem;
    private javax.swing.JMenuItem logoutMenuItem;
    private javax.swing.JMenuBar opcoesMenuBar;
    private javax.swing.JMenuItem sobreMenu;
    // End of variables declaration//GEN-END:variables
}
